<%@ page contentType="text/html; charset=utf-8"%>
<%@ include file="/global/jsp-header.jsp"%>
<c:set var="workerRoleOperatorVisable" value="${d:accessUri(actionUri,pageContext.request) }"></c:set>
<!DOCTYPE HTML>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html">
		<title>角色列表</title>
		<%@ include file="/global/tablesort-header.jsp"%>
		<script>
		var rs = "${workerPager.list.size()}";
		rs = ((!rs)? 0 : parseInt(rs))+1;
		var h = rs * 80 + 50;
		$(window.parent.document).find("#queryResult").removeClass("hide");
		$(window.parent.document).find("#queryResultIframe").height(h);
		
		$(function(){
			$('#checkAll').on("click",function(){
				if($(this).attr('checked')){					
					$('input[name=workerIds]').attr('checked',$(this).attr('checked'));
				}else{
					$('input[name=workerIds]').removeAttr('checked');
				}
			});
			
			<c:if test="${workerRoleOperatorVisable }">
			$('#operatorBtn').on("click",function(){
				var workerIds=new Array();	
				$('input[name=workerIds]:checked').each(function(){
						workerIds.push($(this).val());
				});
				if(workerIds.length > 0){
					$.ajax({  
						type: "post", 
						url: "${actionUri}", 
						data: "workerIds="+workerIds+"&role.roleId=${role.roleId}",
						success: function(msg){  
							$(window.parent.document).find("#myform").submit();  
							window.parent.editDeptTip(msg);
						} 
					});
				}
			});
			</c:if>
		});
		</script>
	</head>
	<body>
		<c:if test="${workerPager.list.size() > 0}">
			<div class="pagertoleft clearBoth">
				<%@ include file="/global/pager-default.jsp"%>
			</div>
			<table id="myTable" cellspacing="1" class="tablesorter">
				<thead>
					<tr>
						<th class="{sorter:false}">
							<input type="checkbox" id="checkAll"/>全选
						</th>
						<th>
							部门
						</th>
						<th>
							组别
						</th>
						<th>
							姓名
						</th>
						<th>
							工号
						</th>
						<th>
							职位
						</th>
					</tr>
				</thead>
				<tbody>
					<c:forEach items="${workerPager.list }" var="item">
						<tr>
							<td>
								<input type="checkbox" name="workerIds" value="${item.workerId }"/>
							</td>
							<td>
								<d:workerHelper type="dept" workerId="${item.workerId }"/>
							</td>
							<td>
								<d:workerHelper type="group" workerId="${item.workerId }"/>
							</td>
							<td>
								${item.workerName }
							</td>
							<td>
								${item.workerId }
							</td>
							<td>
								${item.rank }
							</td>
						</tr>
					</c:forEach>
				</tbody>
			</table>
			<c:if test="${workerRoleOperatorVisable }">
			<button type="button" class="button blue" id="operatorBtn">确定操作</button>	
			<div id="message-dialog" title="消息">
				<p id="msgcontent"></p>
			</div>
			</c:if>
		</c:if>
		<c:if test="${workerPager.list.size() <= 0}">
			<div class="emptyResult">
				抱歉，没有找到相关员工。
			</div>
		</c:if>
	</body>
</html>
